/*
 * @Description: 默认左右布局，右边占据剩余空间
 * @Version: V1.0.0
 * @Author: 黄鑫
 * @Date: 2024-08-19 11:11:38
 * @LastEditors: 黄鑫
 * @LastEditTime: 2024-12-23
 * @FilePath: FlexItem.dart
 * @Props: 
 * @Remarks: 
 */

import 'package:flutter/widgets.dart';

class FlexItem extends StatelessWidget {
  // 左边view
  Widget leftView;
  // 右边view
  Widget rightView;

  // 主轴布局
  MainAxisAlignment? mainAxisAlignment;

  // 纵轴布局
  CrossAxisAlignment? crossAxisAlignment;

  // 组件margin
  EdgeInsetsGeometry? margin;

  EdgeInsetsGeometry? padding;

  BoxDecoration? decoration;

  FlexItem({
    super.key,
    required this.leftView,
    required this.rightView,
    this.mainAxisAlignment,
    this.crossAxisAlignment,
    this.margin,
    this.padding,
    this.decoration,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: decoration,
      margin: margin,
      padding: padding,
      child: Row(
        mainAxisAlignment: mainAxisAlignment ?? MainAxisAlignment.start,
        crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.center,
        children: [
          leftView,
          Expanded(
            flex: 1,
            child: rightView,
          ),
        ],
      ),
    );
  }
}
